<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="com.iwords.constants.QueryConstants"%>
<%@ page import="com.iwords.service.object.*"%>
<div id="fy">
	<input type="hidden" name="toPage" value=${query.toPage}> <input
		type="hidden" name="perPageSize" value=${query.perPageSize}>

	<%
		Query query = (Query) request.getAttribute("query");

		if (query == null || query.getToPage() <= 1) {
	%>

	<img src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/fy_first2.gif"
		width="16" height="16" align="absmiddle" alt="首页" /><font
		color="#999999">首页</font> <img
		src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/fy_back2.gif"
		width="16" height="16" align="absmiddle" alt="上一页" /><font
		color="#999999">上一页</font>



	<%
		} else {
	%>
	<a href="#" onClick="changePage(1)"><img
		src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/fy_first.gif"
		width="16" height="16" align="absmiddle" alt="首页" />首页</a> <a href="#"
		onClick="changePage(-1)"><img
		src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/fy_back.gif"
		width="16" height="16" align="absmiddle" alt="上一页" />上一页</a>




	<%
		}
	%>


	<img src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/sx2_b.gif"
		width="2" height="13" align="absmiddle" /> Page<input type="text"
		id="inputToPage" size="1" value="${query.toPage}" />of
	${query.totalPage} <img
		src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/sx2_b.gif" width="2"
		height="13" align="absmiddle" />

 		<font color="#999999">下一页</font>
		<img
			src="<%=QueryConstants.WEB_RESOURCE_ROOT%>/images/fy_forward2.gif"
			width="16" height="16" align="absmiddle" alt="下一页" />
 

</div>

<script language="javascript">
	$(document).ready(function() {
		$('#sel_pn_rownum').change(onchangePageBysel);
		$('#inputToPage').keydown(onInputPageNum);
		//$('#inputToPage').blur(onInputPageNumBlur);
	});

	function changePage(page) {
		if (page == -1) {

			page = page - 1;
		} else if (page == -2) {

			page = page + 1;
		}

		if (checknumber(page) == false || page <= 0) {
			page = 1;
		}
		$("#toPage").val(page);
		doSearch();

	}

	function onchangePageBysel() {
		$('#perPageSize').val($('#sel_pn_rownum').val());
		changePage(1);
	}

	function checknumber(str) {
		var reg = /^[0-9]*$/;
		return (reg.test(str));
	}
	function onInputPageNum(e) {
		if (e.keyCode == 13) {
			changePage($(this).val());
		}
	}
	function onInputPageNumBlur() {
		changePage($('#inputToPage').val());
	}

	function initPageNum() {
		$("#toPage").val(1);
	}
</script>